/**
 * @module 首页
 * @author Yun Tang
 * @date 2020-05-23 16:50:24
 */

import React, { useState, useEffect } from 'react';
import { Button } from 'antd-mobile';
import Health from './components/Health';
import request from '@src/utils/request';
import { RouteComponentProps } from 'react-router';
import './index.less';

const Home = (props: RouteComponentProps) => {

  const confirm = () => {
    request('get', '/wp-json/ec-visit/v1/is_login').then((res: any) => {
      console.log(res, 'res')
      const data = res.data;
      if (data.code === 1) {
        props.history.push('/login');
      } else {
        props.history.push(`/orderdetail/${data.data.phone}`);
      }
    });
  };

  const [healthVis, setHealthVis] = useState(false);

  return (
    <>
      <section className="main">
        <img src={require('./imgs/home-img.png')} alt="homeImg" />
        <p>
          <i>◆</i>
          <i>◆</i>生态设计小镇会议中心参观预约<i>◆</i>
          <i>◆</i>
        </p>
        <article>
          <p>参观须知：</p>
          <p>1. 请您至少提前一天， 即至少在参观日的前一天与我们预约；</p>
          <p>2. 原则上每个时间段的参观人数上限为50人；</p>
          <p>3. 参观时间：上午10:00-12:00，下午14:00-17:00 逢周一闭馆；</p>
          <p>
            4. 疫情防控期间， 入馆须出示有效身份证件、进行健康码体温检测登记，
            参观要求全程佩戴口罩， 请遵守小镇的参观规定。
          </p>
        </article>
        <Button type="primary" className="orderBtn" onClick={() => setHealthVis(true)}>
          立即预约
        </Button>
      </section>
      {/* 健康申明 */}
      <Health healthVis={healthVis} confirm={confirm} close={() => setHealthVis(false)} />
    </>
  );
};

export default Home;
